package com.gemini.web.servlet;

import com.gemini.pojo.Brand;
import com.gemini.service.impl.BrandServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/update")
public class UpdateServlet extends HttpServlet {
    private final BrandServiceImpl brandService=new BrandServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Brand brand = new Brand(Integer.parseInt(request.getParameter("id")),
                request.getParameter("brandName"),
                request.getParameter("companyName"),
                Integer.parseInt(request.getParameter("ordered")),
                request.getParameter("description"),
                Integer.parseInt(request.getParameter("status")));
        brandService.update(brand);
        //        返回查询页面
        request.getRequestDispatcher("/selectAll").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        this.doGet(request, response);
    }
}
